import axios from 'axios'

import { setRSApass,getRSApass } from './JSEncrypt'
// create an axios instance
const service = axios


// request interceptor
service.interceptors.request.use(
  config => {
    // do something before request is sent
    if (config.data) {
      var data = setRSApass(JSON.stringify(config.data))
      // console.log(getRSApass(data))
      config.data = JSON.stringify({ "data":  data})
      // console.log(config.data)
    }
    return config
  },
  error => { 
    // do something with request error
    return Promise.reject(error)
  }
)


export default service
